package com.wenx.v3system.modular.cloud.controller;

import com.wenx.v3core.response.R;
import com.wenx.v3system.modular.cloud.service.SysUserRemoteService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 系统用户远程服务控制器
 *
 * 提供用户认证相关的远程服务接口
 * 基于 Enhanced RBAC 权限模型
 */
@Slf4j
@RestController
@Tag(name = "系统用户远程服务API")
@RequestMapping("/api/v3/sys/user/remote")
@RequiredArgsConstructor
public class SysUserRemoteController {

    private final SysUserRemoteService userRemoteService;

    @GetMapping("/auth-info")
    @Operation(summary = "根据标识符获取用户认证信息", description = "支持用户名、邮箱、手机号等多种登录方式")
    public R getUserAuthInfo(@RequestParam("identifier") String identifier) {
        return userRemoteService.getUserAuthInfo(identifier);
    }

    @GetMapping("/permissions/{userId}")
    @Operation(summary = "获取用户权限")
    public R getUserPermissions(@PathVariable("userId") Long userId) {
        return userRemoteService.getUserPermissions(userId);
    }

    @GetMapping("/roles/{userId}")
    @Operation(summary = "获取用户角色")
    public R getUserRoles(@PathVariable("userId") Long userId) {
        return userRemoteService.getUserRoles(userId);
    }

    @GetMapping("/account-status/{userId}")
    @Operation(summary = "验证账户状态")
    public R isAccountActive(@PathVariable("userId") Long userId) {
        return userRemoteService.isAccountActive(userId);
    }
}